package com.project.nimsen.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.shiro.util.CollectionUtils;
import org.springframework.stereotype.Repository;

import com.project.jdbc.dao.IBaseJdbcDao;
import com.project.jdbc.service.BaseServiceImpl;
import com.project.jdbc.utils.Finder;
import com.project.nimsen.dao.IBaseDao;
import com.project.nimsen.entity.SRoleEntity;
import com.project.nimsen.service.ISRoleService;
@Repository("sRoleService")
public class SRoleServiceImpl extends BaseServiceImpl implements ISRoleService {
	@Resource
	IBaseDao baseDao;
	protected IBaseJdbcDao getBaseDao() {
		return baseDao;
	}
	public SRoleEntity findByUserid(String userId) throws Exception {
		Finder finder = new Finder("select * from S_ROLE where active=0 and ID in (select ROLE_ID from S_USER_ROLE where active!=1 and USER_ID=:USER_ID)");
		finder.setParam("USER_ID", userId);
		List<SRoleEntity> list = baseDao.queryForList(finder, SRoleEntity.class);
		if(CollectionUtils.isEmpty(list))
			return null;
		return list.get(0);
	}
}
